' Test 8 Infinite Pong the Movie (from SB b+ 2018-09-19) update 2021-02-18
' OK loc works fine for locate row; col
' Now try At col; row
' 2021-02-26 Big problem locating at illegal places?? this is broken by changes.
' odd because most recent changes involved strings but am splitting different?


' constants - test new var assignment 2021-02-25
' test extreme spacing conditions for new var assign with extra spaces

' you can put all the spacing you want between end of var and start of "
' but you can't put any space left of variable ??? 

' good as of 2021-02-27 variable assignments have some tolerance of space typos
Paddle1Y = 3
 Paddle2Y = 40
  PaddleWidth = 10
   BoundaryX1 = a[int[x[.5,PaddleWidth]],1]
    BoundaryX2 = s[s[128,int[x[.5,PaddleWidth]]],1]
'. 3 Paddle variables and 2 BoundriesX ;Paddle1Y;/ ;Paddle2Y;/ ;PaddleWidth;/ ;BoundaryX1;/ ;BoundaryX2
  
' ball test new var assignment 2021-02-25
ballX = 64
ballY = 18
ballDX = 2
ballDY = 1

' . Ball variables: ;ballX;/ ;ballY;/ ;ballDX;/ ;ballDY
' just show print before continuing
' inps OK  ...press Enter;OK

' main
[
	Cls 
	GS DrawBoundary\
	GS Paddles\
	GS Ball\
	Show -1
	Wait .05
]

DrawBoundary\
	row = a[Paddle1Y,1]
	[
		At BoundaryX1;row
		. |
		At BoundaryX2;row
		. |
		row = a[row,1]
		Jmp gte[row,Paddle2Y]
	]
Rtn

Paddles\
	paddlex = s[ballX,x[.5,PaddleWidth]]
	At paddleX;Paddle1Y
	. {XXXXXXXX}
	at paddlex;paddle2y
	. {XXXXXXXX}
Rtn

Ball\
	' update ball
	ballX = a[ballX,ballDX]
	ballY = a[ballY,ballDY]
	
	' keep ball in bounds
	If lt[ballX,a[BoundaryX1,1]]
		 ballX = a[BoundaryX1,1]
		ballDX = x[ballDX,-1] 
	Fi
	If   gt[ballX,s[BoundaryX2,1]]
		 ballX = s[BoundaryX2,1]
		ballDX = x[ballDX,-1] 
	Fi
	If 	 lt[ballY,a[Paddle1Y,1]]
		 ballY = a[Paddle1Y,1] 
		ballDY = x[ballDY,-1] 
		ballDX = a[ballDX,int[rnd[3]],-1]
	Fi
	If   gt[ballY,s[Paddle2Y,1]]
		 ballY = s[Paddle2Y,1]
		ballDY = x[ballDY,-1] 
		ballDX = a[ballDX,int[rnd[3]],-1]
	Fi
	At ballX;ballY
	. O
Rtn